<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:t="http://www.pagac.cz/jsf"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
 <h:head></h:head>
 <h:body>
    <ui:composition template="/WEB-INF/templates/template-insystem.xhtml">

        <!-- Toolbar -->
        <ui:define name="toolbar-place">
            <t:toolbar>
                <t:icon iconName="home" action="goHome" label="#{msgs['toolbar.home']}" />
                <t:icon iconName="back" action="project/detail" label="#{msgs['toolbar.back']}" />
                <t:icon iconName="print" action="printPage" label="#{msgs['toolbar.print']}" />
                <t:separator />
                <!-- Granularity selection -->
                <t:icon iconName="more" action="more" backingBean="#{taskintervalManager}" label="#{msgs['toolbar.more']}"
                        bean="true" ajaxExecute="@this" ajaxRender="@all" formId="moreNavLink"
                        renderedBean="#{taskintervalManager.paginator}" renderedAction="moreSafe" />
                <t:icon iconName="less" action="less" backingBean="#{taskintervalManager}" label="#{msgs['toolbar.less']}"
                        bean="true" ajaxExecute="@this" ajaxRender="@all" formId="lessNavLink"
                        renderedBean="#{taskintervalManager.paginator}" renderedAction="remainsSomething" />
                <t:separator />
                <!-- AJAX navigation -->
                <t:icon iconName="first" action="first" backingBean="#{taskintervalManager}" label="#{msgs['toolbar.first']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="firstNavLink"
                    renderedBean="#{taskintervalManager.paginator}" renderedAction="hasPreviousPage" />
                <t:icon iconName="prev" action="previous" backingBean="#{taskintervalManager}" label="#{msgs['toolbar.previous']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="prevNavLink"
                    renderedBean="#{taskintervalManager.paginator}" renderedAction="hasPreviousPage" />
                <t:textIcon>
                    <h:outputFormat value="&nbsp;#{msgs['app.paging.displayInfo']}">
                        <f:param value="#{taskintervalManager.paginator.pageFirstItem + 1}" />
                        <f:param value="#{taskintervalManager.paginator.pageLastItem + 1}" />
                        <f:param value="#{taskintervalManager.paginator.itemsCount}" />
                    </h:outputFormat>
                    <h:outputText value=" (#{msgs['app.paging.page']} #{taskintervalManager.paginator.actualPage + 1}) " />
                </t:textIcon>
                <t:icon iconName="next" action="next" backingBean="#{taskintervalManager}" label="#{msgs['toolbar.next']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="nextNavLink"
                    renderedBean="#{taskintervalManager.paginator}" renderedAction="hasNextPage" />
                <t:icon iconName="last" action="last" backingBean="#{taskintervalManager}" label="#{msgs['toolbar.last']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="lastNavLink"
                    renderedBean="#{taskintervalManager.paginator}" renderedAction="hasNextPage" />
            </t:toolbar>
        </ui:define>

        <!-- Title -->
        <ui:define name="content-title">
            <h1>#{msgs["task.detail.title"]}</h1>
        </ui:define>

        <!-- Content -->
        <ui:define name="content">
            <c:if test="#{taskManager.task.idProject == -1}">
                <script language="JavaScript">
                   window.location="../project/list.jsf";
                </script>
            </c:if>

           <br />
           <h:outputStylesheet name="cssDetail.css" library="css" />
           <h:panelGrid columns="2" styleClass="panelDetail">
             <h:outputLabel>#{msgs["task.detail.name"]}</h:outputLabel>
             <h:outputLabel>#{taskManager.task.name}</h:outputLabel>

             <h:outputLabel>#{msgs["task.detail.project"]}</h:outputLabel>
             <h:outputLabel>#{taskManager.projectName}</h:outputLabel>

             <h:outputLabel>#{msgs["task.detail.cost"]}</h:outputLabel>
             <h:outputLabel>#{taskManager.task.overheadCost}</h:outputLabel>

             <h:outputLabel>#{msgs["task.detail.time"]}</h:outputLabel>
             <h:outputLabel>#{taskintervalManager.totalTime}</h:outputLabel>

             <h:outputLabel>#{msgs["task.detail.start"]}</h:outputLabel>
             <h:outputLabel>#{taskintervalManager.firstWork}</h:outputLabel>

             <h:outputLabel>#{msgs["task.detail.end"]}</h:outputLabel>
             <h:outputLabel>#{taskintervalManager.lastWork}</h:outputLabel>

             <h:outputLabel>#{msgs["task.detail.note"]}</h:outputLabel>
             <h:outputLabel>#{taskManager.task.note}</h:outputLabel>

           </h:panelGrid>

            <c:choose>
                <c:when test="#{taskintervalManager.taskintervalsCount > 0}">
                    <br />
                    <h2><h:outputLabel>#{msgs["task.detail.intervals"]}</h:outputLabel></h2>

                    <!-- Task Listing -->
                    <h:outputStylesheet name="cssTable.css" library="css" />
                    <h:outputScript library="scripts" name="timer.js" />
                    <h:dataTable id="taskTable"
                                 value="#{taskintervalManager.list}"
                                 var="taskinterval"
                                 styleClass="listing"
                                 rowClasses="odd,even"
                                 columnClasses="time, time, time, note, actions">

                        <t:column  headerCssStyle="listing-header"  sort="false" entity="${taskinterval}"
                                   fieldName="from" backingBean="#{taskintervalManager}"
                                   label="#{msgs['task.detail.intervalList.from']}">
                            #{taskintervalManager.startTimeString}
                        </t:column>

                        <t:column  sort="false" entity="${task}"
                                   fieldName="to" backingBean="#{taskintervalManager}"
                                   label="#{msgs['task.detail.intervalList.to']}">
                            #{taskintervalManager.stopTimeString}
                        </t:column>
                        <t:column  sort="false" entity="${task}"
                                   fieldName="time" backingBean="#{taskintervalManager}"
                                   label="#{msgs['task.detail.intervalList.time']}">
                            #{taskintervalManager.intervalLength}
                            
                        </t:column>

                        <t:column  sort="false" entity="${task}"
                                   fieldName="note" backingBean="#{taskintervalManager}"
                                   label="#{msgs['task.detail.intervalList.note']}">
                            #{taskinterval.note}
                        </t:column>

                        <t:columnCommand label="#{msgs['user.project.list.actions']}">
                            <h:commandButton value="#{msgs['user.project.detail.tasklist.actions.remove']}" action="#{taskintervalManager.remove}"
                                             onclick="return confirm('#{msgs['user.tasklist.detail.actions.removeConfirm']}');">
                                <f:ajax execute="@all" render="@all" onevent="showIndicator" />
                            </h:commandButton>
                        </t:columnCommand>
                    </h:dataTable>

                </c:when>
                <c:otherwise>
                    <p class="warning-messages-noitems">
                        #{msgs['app.listing.task.no-records']}
                    </p>
                </c:otherwise>
            </c:choose>
       </ui:define>

    </ui:composition>

</h:body>
</html>
